@layout("/common/_curd/_container.html"){

<script type="text/javascript">
	var ctx = "${basePath}";
	var grid_selector = "#grid-table";
	var pager_selector = "#grid-pager";

	$(function(){
		var userid = ""
		var ajaxURL = "/user/getuser";
		$.post(ajaxURL,null,function (res) {
			did = res.did
			$('#did').val(did)
			initGrid();
		});
		initMenuBtn("btns", "${code}");
	});

	function initGrid(){
		var grid_url = ctx + "/buynum/list";
		var _colnames = ["主键",
			"提交人",
			"采购单位",
			"临时",
			"提交时间",
			"查看详情",
			"审核状态",
			"提交人"];
		var _colmodel = [{name:"id", index:"id", hidden:true,width:100},
			{name:"uname", index:"uname", width:100},
			{name:"fullname", index:"fullname", width:100},
			{name:"did", index:"did",hidden:true, width:100},
//			{name:"did", index:"did", width:100,formatter:function (value, row, index) {
//				var src = "nopic.jpg";
//				if(value!=null){
//					src = value;
//					src = src.split(",");
//					src = src[1]
//				}
//
//				console.log("src = /upload/"+src)
//
//				return  '<image height="75px" width="100px" src="/upload/'+src+'"></image>';
//			}},
			{name:"date", index:"date", width:100},
			{name:"date", index:"date", width:100,formatter:function (value, row, index) {
				return '<a href="#" class="btn btn-btn btn-success btn-xs" onclick="viewcontain('+"'"+index.id+"'"+')">'+"查看详情"+'</a>';
			}},
			{name:"status", index:"status", width:100,formatter:function (value, row, index) {
				return '<a href="#" class="btn btn-btn btn-success btn-xs" onclick="pass('+"'"+index.id+"'"+')">'+"通过"+'</a>&nbsp;'+
						'<a href="#" class="btn btn-btn btn-danger btn-xs" onclick="back('+"'"+index.id+"'"+')">'+"驳回"+'</a>';
			}},
			{name:"uid", index:"uid",hidden:true, width:100}];

		jQuery(grid_selector).jqGrid({
			url : grid_url,
			shrinkToFit : true,
			colNames : _colnames,
			colModel : _colmodel,
			jsonReader : {id :"id"},
			pager : pager_selector,
			postData : {sort : "id",
//				where:"{status:1,did:"+$('#did').val()+"}",
				where:"{status:1}",
				order : "desc"}
		});
	}
</script>





<!-- 配置 grid -->
<input type="hidden" value="" id="did">
<div class="row">
	<div class="col-xs-12 tb-grid">
		<!-- 配置 查询 -->
		<!-- 按钮 -->
		<!--<div class="welljq well-sm" id="btns"></div>-->
		<!-- grid -->
		<table id="grid-table"></table>
		<!-- 分页-->
		<div id="grid-pager"></div>
	</div>
</div>

<!-- 引入所需的js -->
@include("/common/_listscript.html"){}
<script>
	viewcontain = function (id) {
			layer.open({
				type: 2,
				title: '查看详情',
				shadeClose: true,
				area: ['100%', '100%'],
				content: '/buy/viewcontain?id='+id//iframe的url

			})
	}
	pass=function (ids) {
		console.log(ids);
		ajaxData = {id:ids,pass:2};
		$.post("/buy/pass",ajaxData,function (res) {
			if(res["success"]){
				layer.msg("操作成功！", {shift: -1,time:500,end:function () {
					jQuery("#grid-table").trigger("reloadGrid");
				}});
			}
		});
	}
	back=function (ids) {
		ajaxData = {id:ids,pass:3};
		$.post("/buy/pass",ajaxData,function (res) {
			if(res["success"]){
				layer.msg("操作成功！", {shift: -1,time:500,end:function () {
					jQuery("#grid-table").trigger("reloadGrid");
				}});
			}
		});
	}
</script>
@}